<script>
export default {
  name: 'SendGroupMessage',
  data() {
    return {
      innerVisible: false,
      form: {
        content: '',
        sfbt: false
      }
    }
  },
  methods: {
    openDialog() {
      this.innerVisible = true
      this.form.content = ''
      this.form.sfbt = false
    },
    save(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$message.success('发送成功！')
          this.$emit('save', this.form)
          this.innerVisible = false
        }
      })
    }
  }
}
</script>

<template>
  <el-dialog
    width="40%"
    title="推送消息"
    :visible.sync="innerVisible"
    append-to-body
  >
    <el-form ref="form" :model="form">
      <el-form-item prop="content" :rules="{ required: true, message: '请输入消息内容', trigger: 'blur' }" label="消息内容">
        <el-input
          v-model="form.content"
          type="textarea"
          placeholder="请输入内容"
          maxlength="50"
          show-word-limit
        />
      </el-form-item>
      <el-form-item prop="sfbt" label="是否必读">
        <el-switch v-model="form.sfbt" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="text" @click="innerVisible = false">取消</el-button>
      <el-button type="primary" @click="save('form')">确认</el-button>
    </div>
  </el-dialog>
</template>

<style scoped>

</style>
